package com.demo.dao.impl;

import org.springframework.stereotype.Repository;

import com.demo.bean.User;
import com.demo.dao.AppDAO;
import com.demo.dao.BaseDAO;
import com.googlecode.ehcache.annotations.Cacheable;
import com.googlecode.ehcache.annotations.TriggersRemove;

@Repository
public class AppDAOImpl extends BaseDAO implements AppDAO {

	public int add(User user) {
		this.saveObj(user);
		return 0;
	}

	private static final String getUser = " from User where user = ? ";
	@SuppressWarnings("unchecked")
	@Cacheable(cacheName="departCache") 
	//@TriggersRemove(cacheName="departCache",removeAll=true) 
	//设定spring的ecache缓存策略,当编辑机构时候,把缓存全部清除掉,以达到缓存那数据同步
	public User get(String user) {
		User us = (User)this.uniqueResult(getUser, new Object[]{user});
		return us;
	}
	
}
